package gestion.camping.vue;

import gestion.camping.dto.Emplacement;
import gestion.camping.utils.MessagesUtil;

import java.util.List;

import javax.swing.JTable;
import javax.swing.ListSelectionModel;

public class TableEmplacement extends JTable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 4325502755576282487L;

	public TableEmplacement(List<Emplacement> listEmplacement) {
	    String [] columnNames = getColumnNames();
	    setModel(new TableEmplacementModel(listEmplacement, columnNames));
	    
	    this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	}
	
	public TableEmplacement(){
		setModel(new TableEmplacementModel(null, getColumnNames()));
		this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	}
	
	public String [] getColumnNames() {
		String [] columnsTitle = {MessagesUtil.formatMessage("emplacement.liste.table.num"),
								  MessagesUtil.formatMessage("emplacement.liste.table.secteur"), 
								  MessagesUtil.formatMessage("emplacement.liste.table.typeTerrain")};

	    return columnsTitle;
	}
}
